﻿#pragma once
// Copyright (c) lanyeo 2020-2021
// Licenced under MIT license. See https://opensource.org/licenses/MIT for details.
// code style
// 1. use forward declaration (尽可能使用前置声明)
// 2. include file sequence [other project>c>c++>third>self project]
// 

#pragma warning(disable: 4251)
#include "network.pb.h"
#pragma warning(default: 4251)

#include <cstdint>


/*
 * 使用内存指针位置作为连接的id
 */
typedef void* netlink_t;
const netlink_t INVALID_LINK = (void*)(0);

enum NetworkErrorCode
{
    NETWORK_PACK_TOO_LARGE = -4,
    NETWORK_CONNECT_INVALID = -3,
    NETWORK_SERIALIZE_FAIL = -2,
    NETWORK_FAIL = -1,
    NETWORK_OK = 0,
};

enum RawPackType
{
    RAWPACKTYPE_CLIENT = 1,
    RAWPACKTYPE_RPC = 2,
};

struct NetworkConf
{
    // 最大接受包大小
    uint32_t max_raw_pack_size;
    // 最小接受包大小
    uint32_t min_raw_pack_size;
    // 最大缓存的未处理的接受包大小
    uint16_t max_recv_cache_count;
    // 最大缓存的未发送的接受包大小
    uint16_t max_send_cache_count;
    // tick时间
    uint32_t tick;
};
